
// 此处对ajax 进行了二次封装  => 调用ajax请求,返回进行中状态的Promise实例
function request(url, params = {}, type = "get") {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: type,
            url: url,
            data: { ...params },
            dataType: "json",
            success: function (data) { //形式参数(接口返回的响应数据 )
                resolve(data);
            }
        })
    })
}


// 传入一个对象对象作为参数 {user, pwd, phone, email}
// function register(params) {
//     return request("../php/register.php", params, "post"); // 返回 一个Promise实例
// }
// const register = function (params) {
//     return request("../php/register.php", params, "post"); // 返回 一个Promise实例
// }
// const register = (params) => {
//     return request("../php/register.php", params, "post"); // 返回 一个Promise实例
// }
// const register = params => {
//     return request("../php/register.php", params, "post"); // 返回 一个Promise实例
// }
// const register = params => request("../php/register.php", params, "post");


// function isExistUser(params) {   // {user}
//     return request("../php/isExistUser.php", params, "get"); // 返回 一个Promise实例
// }
// function login(params) {   // {user,pwd}
//     return request("../php/login.php", params, "post"); // 返回 一个Promise实例
// }

// 改箭头函数
const register = params => request("../php/register.php", params, "post");
const isExistUser = params => request("../php/isExistUser.php", params);
const isExistPhone = params => request("../php/isExistPhone.php", params);
const isExistEmail = params => request("../php/isExistEmail.php", params);

const login = params => request("../php/login.php", params, "post");
const loginAccount = params => request("../php/login_account.php", params, "post");

const searchGradeOrderLimit = params => request("../php/searchGradeOrderLimit.php", params);
const deleteGradeById = params => request("../php/deleteGradeById.php", params);
const searchGradeById = params => request("../php/searchGradeById.php", params);
const updateGradeById = params => request("../php/updateGradeById.php", params);

